IdeaBlade.EntityModel.Compat Assembly > IdeaBlade.EntityModel.Compat Namespace > EntityManagerAsyncExtensions Class > SaveChangesAsync Method : SaveChangesAsync(EntityManager,SaveOptions,Action<EntitySaveOperation>,Object) Method |
'Declaration
<ExtensionAttribute()> Public Overloads Shared Function SaveChangesAsync( _ ByVal em As EntityManager, _ ByVal saveOptions As SaveOptions, _ ByVal userCallback As Action(Of EntitySaveOperation), _ Optional ByVal userState As Object _ ) As EntitySaveOperation
'Usage
Dim em As EntityManager Dim saveOptions As SaveOptions Dim userCallback As Action(Of EntitySaveOperation) Dim userState As Object Dim value As EntitySaveOperation value = EntityManagerAsyncExtensions.SaveChangesAsync(em, saveOptions, userCallback, userState)
[Extension()] public static EntitySaveOperation SaveChangesAsync( EntityManager em, SaveOptions saveOptions, Action<EntitySaveOperation> userCallback, object userState )
The asynchronous save operation cannot itself be cancelled. However, you can cancel the save process on the client before the save starts in a Saving event handler. You can also cancel the save process on the server in an EntityServerSaveInterceptor prior to executing the save to the data source. If you do cancel the save the returned IdeaBlade.EntityModel.SaveResult will indicate that the save processing was cancelled.
public void AsyncSaveSimple() { DomainModelEntityManager mgr = new DomainModelEntityManager(); Customer c1 = new Customer() { CompanyName = "Toys R Us" }; mgr.AddEntity(c1); Customer c2 = new Customer() { CompanyName = "Apple" }; mgr.AddEntity(c2); // Save all modified entities using default SaveOptions. // Use a lambda expression which takes the EntitySaveOperation. // The userstate token is left null since it's optional. mgr.SaveChangesAsync(op => { SaveResult sr = op.SaveResult; MessageBox.Show(sr.Ok.ToString()); }, null); }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2